Skip to content

[SYNCOPE-1980] Fix empty audit history diff under Jackson 3#1439

Merged
ilgrosso merged 1 commit into
apache:masterfrom
ozimakov:SYNCOPE-1980
Jun 25, 2026
Merged

[SYNCOPE-1980] Fix empty audit history diff under Jackson 3#1439
ilgrosso merged 1 commit into
apache:masterfrom
ozimakov:SYNCOPE-1980

Conversation

@ozimakov

Copy link
Copy Markdown
Contributor

SYNCOPE-1980

Problem

In the admin console, the per-entity "Audit History" modal (User / Group / Any Object / Realm / Policy → View Audit History) never renders a JSON diff: both the "previous" and "after" panes are always empty, for any selected versions.

Root cause

AuditHistoryDetails#toJSON deserializes the audited entity with an untyped reader:

T entity = MAPPER.reader().
        with(StreamReadFeature.STRICT_DUPLICATE_DETECTION).
        readValue(content);

Under Jackson 3 an ObjectReader with no configured value type throws InvalidDefinitionException: No value type configured for ObjectReader. The exception is swallowed by the surrounding try/catch and toJSON returns an empty Model, so the failure is silent in the UI and only visible in the console log. This is a regression from the Jackson 2 → 3 migration (tools.jackson.*): Jackson 2's mapper.reader() tolerated a missing root type, Jackson 3 requires one.

Fix

Read into the concrete type of the entity, which the panel already holds as currentEntity:

@SuppressWarnings("unchecked")
T entity = (T) MAPPER.readerFor(currentEntity.getClass()).
        with(StreamReadFeature.STRICT_DUPLICATE_DETECTION).
        readValue(content);

The JSON's _class is then consumed as an ordinary property and the entity deserializes correctly for User/Group/AnyObject/Realm/Policy.

Testing

Verified locally against the standalone (H2) distribution: the diff renders and the InvalidDefinitionException no longer appears in the console log. Full reactor test suite passes.

AuditHistoryDetails.toJSON() deserialized the audited entity with an untyped
MAPPER.reader(), which Jackson 3 rejects with InvalidDefinitionException
("No value type configured for ObjectReader"). The exception was swallowed by
the surrounding catch, so the before/after diff panes always rendered empty.

Read into the concrete type of currentEntity so the reader has a value type.
@ilgrosso

Copy link
Copy Markdown
Member

@ozimakov thanks for this fix.

One small note: since Syncope 4.0, the local distribution is not based on H2 but embedded PostgreSQL.

@ilgrosso ilgrosso merged commit 1fee4fb into apache:master Jun 25, 2026
27 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants